//
//  CYMyQuestionTableViewCell.m
//  cyydt
//
//  Created by chu on 2019/1/21.
//  Copyright © 2019 chu. All rights reserved.
//

#import "CYMyQuestionTableViewCell.h"

@implementation CYMyQuestionTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setModel:(CYMyQuestionModel *)model{
    _model = model;
    self.titleLabel.text = model.title;
    self.leftLabel.textColor = RGBOF(0x999999);
    self.titleLabel.textColor = RGBOF(0x333333);

    if ([model.status integerValue] == 0) {
        //未审核
        self.leftLabel.text = @"0回答";
        self.midLabel.text = @"0收藏";
    }else if ([model.status integerValue] == 1){
        //通过
        self.leftLabel.textColor = RGBOF(0x999999);

        self.leftLabel.text = [NSString stringWithFormat:@"%@回答",model.answerNum];
        self.midLabel.text = [NSString stringWithFormat:@"%@收藏",model.collectionNum];
        self.rightLabel.text = model.createTime;
    }else if ([model.status integerValue] == 2){
        //审核未通过
        self.titleLabel.textColor = RGBOF(0x999999);
        self.leftLabel.textColor = RGBOF(0xF43636);
        self.leftLabel.text = model.remark;
    }else if ([model.status integerValue] == 3){
        //删除
    }
    
    self.rightLabel.text = model.createTime;
}

- (void)setVideoModel:(CYMyQuestionModel *)videoModel{
    _videoModel = videoModel;
    
    self.titleLabel.text = videoModel.title;
    self.leftLabel.text = videoModel.category;
    self.midLabel.text = videoModel.createTime;
    if ([videoModel.status integerValue] == 0) {
        //全部
        self.rightLabel.text = @"全部";
    }else if ([videoModel.status integerValue] == 1){
        //待审核
        self.rightLabel.text = @"待审核";
    }else if ([videoModel.status integerValue] == 2){
        //审核通过
        self.rightLabel.text = @"通过";
    }else if ([videoModel.status integerValue] == 3){
        //未通过
        self.rightLabel.text = @"未通过";
    }else if ([videoModel.status integerValue] == 4){
        //草稿箱
        self.rightLabel.text = @"草稿箱";
    }
}

- (void)setWenzhangModel:(CYMyQuestionModel *)wenzhangModel{
    _wenzhangModel = wenzhangModel;
    self.titleLabel.text = wenzhangModel.title;
    self.leftLabel.text = wenzhangModel.category;
    self.midLabel.text = wenzhangModel.createTime;
    if ([wenzhangModel.status integerValue] == 0) {
        //全部
        self.rightLabel.text = @"全部";
    }else if ([wenzhangModel.status integerValue] == 1){
        //待审核
        self.rightLabel.text = @"待审核";
    }else if ([wenzhangModel.status integerValue] == 2){
        //审核通过
        self.rightLabel.text = @"通过";
    }else if ([wenzhangModel.status integerValue] == 3){
        //未通过
        self.rightLabel.text = @"未通过";
    }else if ([wenzhangModel.status integerValue] == 4){
        //草稿箱
        self.rightLabel.text = @"草稿箱";
    }
}

- (void)setJingxuanModel:(CYProjectModel *)jingxuanModel{
    _jingxuanModel = jingxuanModel;

    if ([jingxuanModel.isRead isEqualToString:@"0"]) {
        //未读
        [self setAttributeTextWithLabel:self.titleLabel text:[NSString stringWithFormat:@"%@  ",jingxuanModel.title]];
    }else{
        self.titleLabel.text = jingxuanModel.title;
    }

    self.leftLabel.text = [NSString stringWithFormat:@"%@    %@评论    %@", _jingxuanModel.industry, _jingxuanModel.commentNum, _jingxuanModel.time];
    
}

- (void)setNoticeModel:(CYMyQuestionModel *)noticeModel{
    _noticeModel = noticeModel;
    if ([noticeModel.isRead isEqualToString:@"0"]) {
        //未读
        [self setAttributeTextWithLabel:self.titleLabel text:[NSString stringWithFormat:@"%@  ",noticeModel.title]];
    }else{
        self.titleLabel.text = noticeModel.title;
    }
    self.leftLabel.text = noticeModel.updateTime;
}

- (void)setAttributeTextWithLabel:(UILabel *)label text:(NSString *)text{
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:text];
    
    [attributedString addAttribute:NSForegroundColorAttributeName value:RGBOF(0xA7BBD9) range:NSMakeRange(0, text.length)];
    [attributedString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:15] range:NSMakeRange(0, text.length)];
    
    NSTextAttachment *attchMent = [[NSTextAttachment alloc] init];
    attchMent.bounds = CGRectMake(0, 0, 3, 12);//设置frame
    attchMent.image = [UIImage imageNamed:@"yuan"];//设置图片
    NSAttributedString *att = [NSAttributedString attributedStringWithAttachment:attchMent];
    [attributedString appendAttributedString:att];
    label.attributedText = attributedString;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
